﻿using AutoMapper;
using BBICMS.Application.InputModels;
using BBICMS.Application.InputModels.Articles;
using BBICMS.Application.InputModels.Pages;
using BBICMS.Application.InputModels.Products;
using BBICMS.Application.InputModels.Works;
using BBICMS.Application.ViewModels;
using BBICMS.Application.ViewModels.Front;
using BBICMS.DTO;
using BBICMS.Model;
using BBICMS.Model.DTO;
using BBICMS.Model.Security;
using BBICMS.Model.ViewModel.Identity;
using BBICMS.Model.Works;
using System.Collections.Generic;

namespace BBICMS.WebUI.Mapping
{

    public class DomainToViewModelMappingProfile : Profile
    {
        public override string ProfileName
        {
            get { return "DomainToViewModelMappings"; }
        }
        public DomainToViewModelMappingProfile()
        {
            CreateMap<Post, PostIM>();

            CreateMap<User, EditProfileVM>();
            CreateMap<Menu, MenuDTO>();
            CreateMap<Product, ProductDTO>();
            CreateMap<Product, ProductIM>();
            CreateMap<Product, ProductVM>();
            CreateMap<Product, ProductDetailVM>();

            CreateMap<Category, CategoryDTO>();
            CreateMap<Work, WorkIM>();
            CreateMap<Solution, SolutionIM>();
            CreateMap<Client, ClientIM>();
            CreateMap<Language, LanguageIM>();
            CreateMap<ProductCategory, ProductCategoryIM>();

            CreateMap<ProductCategoryLang, ProductCategoryVM>()
                .ForMember(x => x.Id, opt => opt.MapFrom(source => source.Category.Id))
                .ForMember(x => x.Active, opt => opt.MapFrom(source => source.Category.Active))
                .ForMember(x => x.Importance, opt => opt.MapFrom(source => source.Category.Importance));
           
            CreateMap<ProductCategoryLang, ProductCategoryLangIM>();
            CreateMap<Language, ProductCategoryLangIM>();
            CreateMap<Language, ProductCategoryLang>();

            //CreateMap<SerieLang, SerieVM>()
           //.ForMember(x => x.Id, opt => opt.MapFrom(source => source.Serie.Id))
           //.ForMember(x => x.Active, opt => opt.MapFrom(source => source.Serie.Active))
           // .ForMember(x => x.Recommend, opt => opt.MapFrom(source => source.Serie.Recommend))
           //.ForMember(x => x.Importance, opt => opt.MapFrom(source => source.Serie.Importance))
           // .ForMember(x => x.Thumbnail, opt => opt.MapFrom(source => source.Serie.Thumbnail));

            //CreateMap<SerieLang, SerieLangIM>();
            //CreateMap<Language, SerieLangIM>();
            //CreateMap<Language, SerieLang>();


 //           CreateMap<ColorLang, ColorVM>()
 //.ForMember(x => x.Id, opt => opt.MapFrom(source => source.Color.Id))
 //.ForMember(x => x.Active, opt => opt.MapFrom(source => source.Color.Active))
 //.ForMember(x => x.Importance, opt => opt.MapFrom(source => source.Color.Importance))
 // .ForMember(x => x.Value, opt => opt.MapFrom(source => source.Color.Value));

 //           CreateMap<ColorLang, ColorLangIM>();
 //           CreateMap<Language, ColorLangIM>();
 //           CreateMap<Language, ColorLang>();


            //CreateMap<QSize, QSizeIM>();
            //CreateMap<BSize, BSizeIM>();
            //CreateMap<QLayout, QLayoutIM>();
            //CreateMap<BLayout, BLayoutIM>();

            CreateMap<ProductPhoto, ProductPhotoIM>();

            CreateMap<PageLang, PageVM>()
     .ForMember(x => x.Id, opt => opt.MapFrom(source => source.Page.Id))
     .ForMember(x => x.Active, opt => opt.MapFrom(source => source.Page.Active))     
     .ForMember(x => x.Importance, opt => opt.MapFrom(source => source.Page.Importance))
      .ForMember(x => x.SeoName, opt => opt.MapFrom(source => source.Page.SeoName))
              .ForMember(x => x.AddedDate, opt => opt.MapFrom(source => source.Page.AddedDate));

            CreateMap<PageLang, PageLangIM>();
            CreateMap<Language, PageLangIM>();
            CreateMap<Language, PageLang>();

        }

        //protected override  void Configure()
        //    {

     

     
        //    //Mapper.CreateMap<GroupUpdate, GroupUpdateFormModel>();
        //    //Mapper.CreateMap<Update, UpdateViewModel>();
        //    //Mapper.CreateMap<GroupUpdate, GroupUpdateViewModel>();
        //    ////Mapper.CreateMap<X, XViewModel>()
        //    ////    .ForMember(x => x.Property1, opt => opt.MapFrom(source => source.PropertyXYZ));
        //    //Mapper.CreateMap<Goal, GoalListViewModel>().ForMember(x => x.SupportsCount, opt => opt.MapFrom(source => source.Supports.Count))
        //    //                                          .ForMember(x => x.UserName, opt => opt.MapFrom(source => source.User.UserName))
        //    //                                          .ForMember(x => x.StartDate, opt => opt.MapFrom(source => source.StartDate.ToString("dd MMM yyyy")))
        //    //                                          .ForMember(x => x.EndDate, opt => opt.MapFrom(source => source.EndDate.ToString("dd MMM yyyy")));
        //    //Mapper.CreateMap<Group, GroupsItemViewModel>().ForMember(x => x.CreatedDate, opt => opt.MapFrom(source => source.CreatedDate.ToString("dd MMM yyyy")));

        //    //Mapper.CreateMap<IPagedList<Group>, IPagedList<GroupsItemViewModel>>().ConvertUsing<PagedListConverter<Group, GroupsItemViewModel>>();


        //}
    }
    
}